{:W("Main",array('module'=>MODULE_NAME,'action'=>ACTION_NAME,'do'=>$_GET['do']))}
<link  href="__PUBLIC__/Assets/js/uploadify/uploadify.css" rel="stylesheet" type="text/css">
<script src="__PUBLIC__/Assets/js/uploadify/jquery.uploadify.js" type="text/javascript"></script>
<script src="__PUBLIC__/Assets/js/layer/layer.js"></script>
<script type="text/javascript">
$(function() {
	$('#file_upload').uploadify({
		'formData'      : {
			'timestamp' : '{$_SERVER["REQUEST_TIME"]}',
			'token'     : '{$_SERVER["REQUEST_TIME"]|MD5}'
		},
		'onUploadSuccess' : function(file, data, response) {
			$('#image').val(data);
			var thumb = $('#thumb');
			if(!thumb.val()) thumb.val(data);
		},
		'swf'         : '__PUBLIC__/Assets/js/uploadify/uploadify.swf',
		'uploader'    : '{:U("Public/upload")}',
		'buttonImage' : '__PUBLIC__/Assets/js/uploadify/swfBnt.png',
		'fileTypeExts': '*.bmp;*.jpg;*.jpeg;*.gif;*.png'//文件格式限制

	});
	$('#file_upload_thumb').uploadify({
		'onUploadSuccess' : function(file, data, response) {
			$('#thumb').val(data);
		},
		'swf'         : '__PUBLIC__/Assets/js/uploadify/uploadify.swf',
		'uploader'    : '{:U("Public/upload")}',
		'buttonImage' : '__PUBLIC__/Assets/js/uploadify/swfBnt.png',
		'fileTypeExts': '*.bmp;*.jpg;*.jpeg;*.gif;*.png'//文件格式限制

	});
});
function upload(btn,input){
	$(btn).uploadify({
		'onUploadSuccess' : function(file, data, response) {
			$(input).val(data);
		},
		'swf'         : '__PUBLIC__/Assets/js/uploadify/uploadify.swf',
		'uploader'    : '{:U("Public/upload")}',
		'buttonImage' : '__PUBLIC__/Assets/js/uploadify/swfBnt.png',
		'fileTypeExts': '*.bmp;*.jpg;*.jpeg;*.gif;*.png'
	});
}
</script>

<div class="layout-main">    
    <div id="breadclumb" class="box">
        <h3><strong>{:lang('breadclumb_colon')}</strong>{:lang(MODULE_NAME)}<span></span><empty name="_GET.id">{:lang('add')}<else />{:lang('edit')}</empty></h3>
    </div>
    <div class="box clear-fix">
		
        <div class="layout-block-header">
			<h2>{:lang('details_info')}<eq name="_GET['do']" value='copy'><b class="alert">【{:lang('item_copy')}】</b></eq></h2>
		</div>  
        <div id="AccountInfo">
            <div class="info-block">
                <form method="post" action="{:U(MODULE_NAME.'/proccess/')}" id="ajaxform" enctype="multipart/form-data">
                <table class="info-table">
                    <tbody>
						<tr>
                            <th><b class="verifing">*</b>{:lang('item_number')}</th>
                            <td>
								<if condition="!empty($_GET['id']) && $_GET['do'] neq 'copy'">
								<input name="sn" type="text" class="ui-text validate[required,minSize[4]]" size="30" value="{$info.sn}" readonly>
								<else />
								<input name="sn" type="text" class="ui-text validate[required,minSize[4],custom[onlyLetterNumber]]" size="30" value="{:randCode(6,'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0987654321')}">
								<span class="ui-validityshower-info">（只能填写字母和数字）</span>
								</if>
							</td>
                        </tr>
                    	<tr>
                            <th><b class="verifing">*</b>{:lang('name_colon')}</th>
                            <td><input name="name" type="text" class="ui-text validate[required,minSize[2]]" size="100" value="{$info.name}"></td>
                        </tr>
						
						<tr class="">
                            <th>推广员</th>
                            <td>
								<input name="promoter" class="ui-text" size="50" id="promoter" type="text" value="{$info.promoter}" >
								
							</td>
                        </tr>
						
						<tr class="">
                            <th>FB像素</th>
                            <td>
								<input name="facebook_pixels" class="ui-text" size="50" id="facebook_pixels" type="text" value="{$info.facebook_pixels}" >
								
							</td>
                        </tr>
						<tr>
                            <th><b class="verifing">*</b>{:lang('category_colon')}</th>
                            <td>
								<select name="category_id" class="validate[required]">
									<volist name="category" id="vo">
									<option value="{$vo.id}" <eq name="info.category_id" value="$vo.id">selected='selected'</eq>>{$vo.name}</option>
									</volist>
								</select>
							</td>
                        </tr>
						<tr>
                            <th>{:lang('qrcode_payment_colon')}</th>
                            <td>
								<select name="qrcode_pay" id="qrcode_pay" onchange="qrcodepay(this.value)">
									<option value="0">不使用二维码</option>
									<option value="1" <eq name="info.qrcode_pay" value="1">selected="selected"</eq>>固定金额二维码</option>
									<option value="2" <eq name="info.qrcode_pay" value="2">selected="selected"</eq>>不定金额二维码</option>
								</select>
								<span class="ui-validityshower-info">（可使用个人微信二维码或支付宝二维码收款）</span>
							</td>
                        </tr>
						<tr class="qrcode <notempty name="info.qrcode_pay">show</notempty>">
                            <th>{:lang('payment_说明_colon')}</th>
                            <td>
								<input name="qrcode_pay_info" class="ui-text" size="50" id="qrcode_pay_info" type="text" value="{$info.qrcode_pay_info}" >
								<span class="ui-validityshower-info">（换行请用&lt;br&gt;）</span>
							</td>
                        </tr>
						
						
						<tr>
                            <th>{:lang('price_colon')}</th>
                            <td>
								<div class="left" style="margin-right: 20px;">
									<label>原价：</label>
									<input name="original_price" class="ui-text" size="4" type="text" value="{$info.original_price}">
									<span class="ui-validityshower-info">{:lang('yuan')}</span>
								</div>

								<label class="left"><b class="verifing">*</b>现价：</label>
								<div class="left">
									<input name="price" type="text" class="ui-text validate[required]" value="{$info.price}" size="4">
									<span class="ui-validityshower-info">{:lang('yuan')}</span>
								</div>
								<div class="left qrcode <notempty name='info.qrcode_pay'>show</notempty>" style="margin-left:20px;">
									<label class="left">{:lang('qrcode_colon')}</label>
									<div class="left">
										<input name="qrcode" type="text" class="ui-text left" value="{$info.qrcode}" id="qrcode"><button id="btn-qrcode" type="button" class="btn-upload left" onclick="upload('#btn-qrcode','#qrcode')"></button>
										<span class="ui-validityshower-info">（收款二维码）</span>
									</div>
								</div>
							</td>
                        </tr>

                        <notempty name="aliziConfig.item_quantity">
                        <tr>
                            <th>商品库存：</th>
                            <td>
                                <input name="quantity" class="ui-text" size="4" type="text" value="{$info.quantity}">
                            </td>
                        </tr>
                        </notempty>
                        <tr>
                            <th>{:lang('sale_quantity_colon')}</th>
                            <td>
                                <input name="salenum" class="ui-text" size="4" type="text" value="{$info.salenum}">
                            </td>
                        </tr>
						<tr>
                            <th>优惠：</th>
                            <td>
								购买 <input name="buy_num" class="ui-text" size="20" type="text" value="{$info.buy_num}"> 件，
								立减 <input name="buy_num_decrease" class="ui-text" size="40" type="text" value="{$info.buy_num_decrease}"> 元。
							</td>
                        </tr>

                        <tr>
                            <th>套餐：</th>
                            <td>
                                <p class="product-list">
                                    <input type="button" class="ui-button" value="添加套餐" onclick="productAdd()" />
                                </p>
								<volist name="set_arrs" id="vo">
                                    <?php $outkey = $key; ?>
                                <div class="product-list" style="margin-top: 10px;">
                                    <table class="table-detail table-product" width="80%">
                                        <tr class="product-item">
                                            <td class="ui-text-right" style="font-weight: bold;">套餐名称：</td>
                                            <td><input style="width: 100%;" class="ui-text" type="text" value="{$vo.title}" name="product_set[{$outkey}]" data-index="{$outkey}"></td>
                                            <td style="width: 70px;"><input type="button" class="ui-button" value="添加商品" onclick="productItemAdd(this)" /></td>
                                            <td style="width: 70px;"><input type="button" class="ui-button" value="删除套餐 " onclick="productDel(this)" /></td>
                                        </tr>

                                        <tr>
                                            <td colspan="3">
                                                <table>
                                                    <tr>
                                                        <td style="width: 70px;">商品ID</td><td style="width: 100px;">商品编号</td><td>商品名称</td><td style="width: 70px;">商品价格</td><td style="width: 70px;">数量</td><td style="width: 100px;">属性</td>
                                                    </tr>
                                                    <volist name="vo['products']" id="vo">
                                                    <tr class="product-item-list">
                                                        <td><input name="product_id[{$outkey}][]"  value="{$vo.product_id}" style="width: 100%;" type="text" class="ui-text product_id"></td>
                                                        <td><input name="product_sn[{$outkey}][]"  value="{$vo.title}" style="width: 100%;" type="text" class="ui-text product_sn"></td>
                                                        <td><input name="product_name[{$outkey}][]"  value="{$vo.product_name}" style="width: 100%;" type="text" class="ui-text product_name"></td>
                                                        <td><input name="product_price[{$outkey}][]" value="{$vo.product_price}" style="width: 100%;" type="text" class="ui-text product_price"></td>
                                                        <td><input name="product_count[{$outkey}][]" value="1" style="width: 100%;" type="text" class="ui-text product_count"></td>
                                                        <td><input name="product_attr[{$outkey}][]" disabled value="{$vo.title}" style="width: 100%;" type="text" class="ui-text product_attr"></td>
                                                        <td style="width: 70px;"><input type="button" class="ui-button" value="选择商品" onclick="selectItem(this)" /></td>
                                                        <td style="width: 70px;"><input type="button" class="ui-button" value="选择属性" onclick="selectAttr(this)" /></td>
                                                        <td style="width: 70px;"><input type="button" class="ui-button" value="删除商品" onclick="productItemDel(this)" /></td>
                                                    </tr>
                                                    </volist>
                                                </table>
                                            </td>
                                        </tr>
                                    </table>
                                </div>
								</volist>
                            </td>
                        </tr>
						<tr>
                            <th>主属性：</th>
                            <td>
								<div>
									<input type="button" class="ui-button" value="添加规格" onclick="itemAdd()" />
									<input type="text" class="ui-text" name="params_name" placeholder="{:lang('package_name')}" value="{$info.params_name}" />
									<select name="params_type">
										<option value="radio">单选项</option>
										<option value="select" <eq name="info.params_type" value="select">selected="selected"</eq>>下拉框</option>
										<option value="checkbox" <eq name="info.params_type" value="checkbox">selected="selected"</eq>>多选项</option>
									</select>
								</div>
                                <div class="item-list">
                                    <table class="table-detail table-params" width="80%">
                                        <tr><th>名称</th><th style="width:70px">价格</th><th style="width:280px;">图片</th><th class="qrcode <notempty name='info.qrcode_pay'>show</notempty>" style="width:200px;">二维码</th><th style="width:50px">操作</th></tr>
                                        <notempty name="info.params">
                                            <volist name="info.params" id="vo">
                                            <tr>
                                                <td><input name="title[]" type="text" class="ui-text" value="{$vo.title}" style="width:100%"></td>
                                                <td><input name="params_price[]" type="text" class="ui-text" value="{$vo.price}" size="4"></td>
                                                <td><input name="params_image[]" type="text" class="ui-text" value="{$vo.image}" id="image-{$key}" size="20" style="float:left;"><button id="btn-image-{$key}" type="button" class="btn-upload" onclick="upload('#btn-image-{$key}','#image-{$key}')"></button></td>
                                                <td class="qrcode <notempty name='info.qrcode_pay'>show</notempty>"><input name="params_qrcode[]" type="text" class="ui-text validate[required]" value="{$vo.qrcode}" id="qrcode-{$key}" size="12" style="float:left;"><button id="btn-qrcode-{$key}" type="button" class="btn-upload" onclick="upload('#btn-qrcode-{$key}','#qrcode-{$key}')"></button></td>
                                                <td><input type="button" class="ui-button" value="{:lang('delete')}" onclick="itemDel($(this))" /></td>
                                            </tr>
                                            </volist>
                                        </notempty>
                                    </table>
								</div>
                            </td>
                        </tr>
						<tr>
                            <th>商品属性：</th>
                            <td>
                                <p>
									<input type="button" class="ui-button" value="添加属性" onclick="itemForm()" />
									<span class="ui-validityshower-info" style="color:#f00">（多个选项内容用#分隔开，如：红色#白色#紫色）</span>
								</p>
								<div class="extend-list">
                                    <table class="table-detail table-extends" width="80%">
                                        <tr><th style="width:85px">名称</th><th>内容</th><th style="width:75px">选择类型</th><th style="width:50px">操作</th></tr>
                                        <notempty name="info.extends">
                                            <volist name="info.extends" id="vo">
                                                <tr>
                                                    <td><input name="extend_title[]" type="text" class="ui-text" value="{$vo.title}" size="8"></td>
                                                    <td><input name="extend_value[]" type="text" class="ui-text" value="{$vo.value}" style="width:100%"></td>
                                                    <td><select name='extend_type[]'><option value='radio' <eq name="vo.type" value="radio">selected</eq>>单选项</option><option value='text' <eq name="vo.type" value="text">selected</eq>>文本框</option><option value='checkbox' <eq name="vo.type" value="checkbox">selected</eq>>多选项</option><option value='select' <eq name="vo.type" value="select">selected</eq>>下拉框</option><option value='password' <eq name="vo.type" value="password">selected</eq>>密码框</option></select></td>
                                                    <td><input type="button" class="ui-button" value="{:lang('delete')}" onclick="itemDel($(this))" /></td>
                                                </tr>
                                            </volist>
                                        </notempty>
                                    </table>

								</div>
                            </td>
                        </tr>

						<tr>
							<th>倒计时：</th>
							<td>
								<input name="timer" type="text" class="ui-text" value="{$info.timer}" size="10">
								<span class="ui-validityshower-info">（ 秒。为空或0则不显示）</span>
							</td>
						</tr>
                        
                        <tr>
                            <th>{:lang('status_colon')}</th>
                            <td>
								<select name="status">{$info.status|status="select"}</select>
								<span class="ui-validityshower-info">（禁用则前台不显示）</span>
							</td>
                        </tr>
				
						<tr>
                            <th>主图片：</th>
                            <td>
                                <div class="main-img-list">
                                    <input name="image" id="image" type="text" class="ui-text" value="{$info.image}" size="80" style="float:left">
                                    <input id="file_upload" name="file_upload" type="file" multiple="true" value="{:lang('upload')}" onclick="upload('#file_upload','#image')">
                                </div>
                            </td>
                        </tr>
						<tr>
                            <th>背景图片：</th>
                            <td>
                                <div class="main-img-list">
                                    <input name="image_bg" id="image_bg" type="text" class="ui-text" value="{$info.image_bg}" size="80" style="float:left">
                                    <input id="file_upload_bg" name="file_upload_bg" type="file" multiple="true" value="{:lang('upload')}" onclick="upload('#file_upload_bg','#image_bg')">
                                </div>
                            </td>
                        </tr>
					
						<tr>
                            <th>{:lang('brief_colon')}</th>
                            <td>
                                <input name="brief" type="text" class="ui-text" value="{$info.brief}" size="80">
								<span class="ui-validityshower-info">（一句话的简介）</span>
                            </td>
                        </tr>
						<tr>
                            <th>{:lang('关键词_colon')}</th>
                            <td>
                                <input name="tags" type="text" class="ui-text" value="{$info.tags}" size="80">
								<span class="ui-validityshower-info">（多个关键词请用#分开）</span>
                            </td>
                        </tr>
                        <tr>
                            <th>{:lang('content_colon')}</th>
                            <td>
								<div>
									<label class="alert">点击向内容框插入以下标签内容：</label>
									<a href="javascript:;" onclick="setContent('{[AliziOrder]}','【订单标签】添加成功')">【订单标签】</a>
									<a href="javascript:;" onclick="setContent('{[AliziComment-1]}','【评论标签】添加成功')">【评论标签】</a>
									<a href="javascript:;" onclick="insertHtml()">【插入代码】</a>

								</div>
                            	<textarea name="content" id="content" class="input-textarea editor" cols="80" rows="6"><empty name="info.content">{[AliziOrder]}<else />{$info.content}</empty></textarea>
                            </td>
                        </tr>
						
						
						<php>$aliziConfig = S('aliziConfig');$payment = C('PAYMENT');$itemPayment=json_decode($info['payment']);</php>
						<empty name="aliziConfig.payment_global">
						<tr>
                            <th>{:lang('payment_colon')}</th>
                            <td>
								<volist name="payment" id="vo">
								<input type="checkbox" name="payment[]" value="{$key}" <if condition="in_array($key,$itemPayment)">checked="checked"</if>>
								<label class="ui-group-label">{$vo.name}</label>
								</volist>
                            </td>
                        </tr>
						</empty>
						
						<tr>
                            <th>{:lang('附加内容_colon')}</th>
                            <td>
								<p><span class="ui-validityshower-info">附加内容可以添加JS/CSS</span></p>
                                <textarea name="remark" id="remark" class="input-textarea" cols="125" rows="3">{$info.remark}</textarea>
                            </td>
                        </tr>
						<tr>
                            <th>{:lang('运费模板_colon')}</th>
                            <td>
                                <select name="shipping_id" id="shipping_id">
									<option value="0">卖家承担运费</option>
									<volist name="shipping" id="vo">
									<option value="{$vo.id}" <eq name="vo.id" value="$info.shipping_id">selected="selected"</eq>>{$vo.name}</option>
									</volist>
								</select>
								<button type="button" class="btn" onclick="shipping()">添加模板</button>
								<a href="{:U('Setting/shipping')}">管理运费模板</a>
                            </td>
                        </tr>
						
						<php>$aliziConfig = S('aliziConfig');</php>
						<tr>
                            <th>{:lang('sms_send_colon')}</th>
                            <td>
								<input name="sms_send[0][status]" type="checkbox" value="1" <notempty name="info['sms_send'][0]['status']">checked="checked"</notempty> onclick="isShow(this,'.sms_send_0')">
								<span class="ui-validityshower-info">下单通知</span>
								
								<input name="sms_send[1][status]" type="checkbox" value="1" <notempty name="info['sms_send'][1]['status']">checked="checked"</notempty> onclick="isShow(this,'.sms_send_1')">
								<span class="ui-validityshower-info">支付通知</span>
								
								<input name="sms_send[3][status]" type="checkbox" value="1" <notempty name="info['sms_send'][3]['status']">checked="checked"</notempty> onclick="isShow(this,'.sms_send_3')">
								<span class="ui-validityshower-info">发货通知</span>

                                <style>.tags span{margin:0 5px;color:#06c;}</style>
								<p class="tags">以下标签将替换为实际发送的内容：<br>标题<span>#title#</span>，套餐<span>#params#</span>，姓名<span>#name#</span>，手机<span>#mobile#</span>，数量<span>#quantity#</span>，价格<span>#price#</span>，快递名称<span>#express#</span>，快递单号<span>#expressNum#</span>，确认网址<span>#confirmUrl#</span></p>
							</td>
                        </tr>
						<tr class="smsSend sms_send_0 <notempty name="info['sms_send'][0]['status']"> show</notempty>">
                            <th>{:lang('下单通知内容_colon')}</th>
                            <td>
								<textarea name="sms_send[0][content]"class="input-textarea" cols="125" rows="3"><notempty name="info['sms_send'][0]['content']">{$info['sms_send'][0]['content']}<else />#name#，您已成功订购#title#，数量#quantity#件，我们将尽快安排发货，感谢支持</notempty></textarea>
							</td>
                        </tr>
						<tr class="smsSend sms_send_1 <notempty name="info['sms_send'][1]['status']"> show</notempty>">
                            <th>{:lang('支付通知内容_colon')}</th>
                            <td>
								<textarea name="sms_send[1][content]" class="input-textarea" cols="125" rows="3"><notempty name="info['sms_send'][1]['content']">{$info['sms_send'][1]['content']}<else />#name#，您已成功订购#title#，价格#price#元，我们将尽快安排发货，敬请留意</notempty></textarea>
							</td>
                        </tr>
						<tr class="smsSend sms_send_3 <notempty name="info['sms_send'][3]['status']"> show</notempty>">
                            <th>{:lang('发货通知内容_colon')}</th>
                            <td>
								<textarea name="sms_send[3][content]" class="input-textarea" cols="125" rows="3"><notempty name="info['sms_send'][3]['content']">{$info['sms_send'][3]['content']}<else />#name#，您订购的#title#，已发#express#，单号#expressNum#，请注意查收</notempty></textarea>
							</td>
                        </tr>
						
                        <tr>
                            <th>&nbsp;</th>
                            <td>
								<if condition="!empty($_GET['id']) && $_GET['do'] neq 'copy'">
								<input type="hidden" name="id" value="{$info.id}" />
								</if>
								<if condition="$_GET['do'] eq 'copy'">
									<input type="hidden" name="item_id" value="{$info.id}" />
								</if>
                                <input type="hidden" name="user_id" value="{$_SESSION.user.id}" />
                                <input type="submit" id="submitBtn" class="btn btn-ok" value="{:lang('confirm')}" />
                                <a class="btn" href="<empty name="_GET.id">{:U('Item/index')}<else />{$_SERVER['HTTP_REFERER']}</empty>">{:lang('goback')}</a>
                            </td>
                        </tr>
                    </tbody>
                </table>
                </form>
            </div>
        </div>  
    </div><!--.box-->
<link href="__PUBLIC__/Assets/js/validation/validationEngine.jquery.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="__PUBLIC__/Assets/js/validation/jquery.validationEngine.js"></script>
<script type="text/javascript" src="__PUBLIC__/Assets/js/validation/jquery.validationEngine-zh_CN.js"></script>
<script type="text/javascript">
$(function(){
	$("#ajaxform").validationEngine('attach', {promptPosition : "centerRight", autoPositionUpdate : true}); 
    $('#ajaxform').ajaxForm({
        timeout: 15000,
        error:function(){ $('#ajaxLoading').hide();alert("{:lang('ajaxError')}");},
        beforeSubmit:function(){ $('#ajaxLoading').show();},
        success:function(data){ 
            $('#ajaxLoading').hide();
            if(data.status==1){
                var redirectURL = "<eq name='_GET.do' value='edit'>#<else />{:U('Item/index')}</eq>";
                $.alert(data.info,data.status,function(){window.location.href=redirectURL});
            }else{
                $.alert(data.info,data.status);
            }
        },
        dataType: 'json'
    });
});

function qrcodepay(id){
	id = parseInt(id);
	if(id>0){$('.qrcode').addClass('show');}else{$('.qrcode').removeClass('show');}
}
function itemAdd(){
	var show = $('#qrcode_pay').val()>0?' show':'';
	var rand = new Date().getTime();
    var item = '<tr></tr><td><input name="title[]" type="text" class="ui-text" value="{$vo.title}" style="width:100%"></td><td><input name="params_price[]" type="text" class="ui-text" value="{$vo.price}" size="4"></td><td><input name="params_image[]" type="text" class="ui-text" value="{$vo.image}" id="image-'+rand+'" size="20" style="float:left;"><button id="btn-image-'+rand+'" type="button" class="btn-upload" onclick="upload(\'#btn-image-'+rand+'\',\'#image-'+rand+'\')"></button></td><td class="qrcode '+show+'"><input name="params_qrcode[]" type="text" class="ui-text validate[required]" value="{$vo.qrcode}" id="qrcode-'+rand+'" size="12" style="float:left;"><button id="btn-qrcode-'+rand+'" type="button" class="btn-upload" onclick="upload(\'#btn-qrcode-'+rand+'\',\'#qrcode-'+rand+'\')"></button></td><td><input type="button" class="ui-button" value="{:lang("delete")}" onclick="itemDel($(this))" /></td></tr>';

    $('.table-params').append(item);
}
function itemDel(obj){
	obj.parent().parent().remove();
}
function itemForm(){
	var show = $('#extend_form').attr('checked')=='checked'?' show':'';
	var rand = new Date().getTime();
    var select = "<select name='extend_type[]'><option value='radio'>单选项</option><option value='text'>文本框</option><option value='checkbox'>多选项</option><option value='select'>下拉框</option></select>";
	//var item = '<div class="rows clearfix"><label>{:lang('name_colon')}</label><input name="extend_title[]" type="text" class="ui-text" value="{$info.title}" size="6"><label> {:lang('内容_colon')}</label><input name="extend_value[]" type="text" class="ui-text" value="" size="60">'+select+'<input type="button" class="ui-button" value="{:lang('delete')}" onclick="itemDel($(this))" /></div>';
    var item = '<tr><td><input name="extend_title[]" type="text" class="ui-text" value="" size="8"></td> <td><input name="extend_value[]" type="text" class="ui-text" value="" style="width:100%"></td><td><select name="extend_type[]"><option value="radio">单选项</option><option value="text">文本框</option><option value="checkbox">多选项</option><option value="select">下拉框</option><option value="password">密码框</option></select></td> <td><input type="button" class="ui-button" value="{:lang("delete")}" onclick="itemDel($(this))" /></td></tr>';
	$('.table-extends').append(item);
}
function isShow(_this,target){
	var target = $(target);
	if(_this.checked==true){
		target.addClass('show');
	}else{
		target.removeClass('show');
	}
}
function shipping(id){
	var url = "?m=Shipping&a=edit&page=2";
	$.open(url,{title:'运费模板',width:680,height:250});
}
function productAdd() {
    var rand = new Date().getTime();
    var index = parseInt($('.product-list').last().find('input[data-index]')[0].dataset.index) + 1;
    var product = '<div class="product-list" style="margin-top: 10px;"><table class="table-detail table-product" width="80%"><tr class="product-item"><td class="ui-text-right" style="font-weight: bold;">套餐名称：</td><td><input style="width: 100%;" class="ui-text" type="text" name="product_set[' + index + ']" data-index="' + index + '"></td><td style="width: 70px;"><input type="button" class="ui-button" value="添加商品" onclick="productItemAdd(this)" /></td><td style="width: 70px;"><input type="button" class="ui-button" value="删除套餐 " onclick="productDel(this)" /></td></tr><tr><td colspan="3"><table><tr><td style="width: 70px;">商品ID</td><td style="width: 100px;">商品编号</td><td>商品名称</td><td style="width: 70px;">商品价格</td><td style="width: 70px;">数量</td><td style="width: 100px;">属性</td></tr><tr class="product-item-list"><td><input name="product_id[' + index + '][]"  value="" style="width: 100%;" type="text" class="ui-text product_id"></td><td><input name="product_sn[' + index + '][]" disabled value="" style="width: 100%;" type="text" class="ui-text product_sn"></td><td><input name="product_name[' + index + '][]"  value="" style="width: 100%;" type="text" class="ui-text product_name"></td><td><input name="product_price[' + index + '][]" value="" style="width: 100%;" type="text" class="ui-text product_price"></td><td><input name="product_count[' + index + '][]" value="1" style="width: 100%;" type="text" class="ui-text product_count"></td><td><input name="product_attr[' + index + '][]" disabled value="" style="width: 100%;" type="text" class="ui-text product_attr"></td><td style="width: 70px;"><input type="button" class="ui-button" value="选择商品" onclick="selectItem(this)" /></td><td style="width: 70px;"><input type="button" class="ui-button" value="选择属性" onclick="selectAttr(this)" /></td><td style="width: 70px;"><input type="button" class="ui-button" value="删除商品" onclick="productItemDel(this)" /></td></tr></table></td></tr></table></div>\n';
    $('.product-list').last().after(product);
}
function productDel(_this) {
    $(_this).parents('.product-list').remove();
}
function productItemAdd(_this) {
    var rand = new Date().getTime();
    var item = $(_this).parents('.product-list').find('input[data-index]')[0].dataset.index;
    var productItem = '<tr class="product-item-list"><td><input name="product_id[' + item + '][]"  value="" style="width: 100%;" type="text" class="ui-text product_id"></td><td><input name="product_sn[' + item + '][]" disabled value="" style="width: 100%;" type="text" class="ui-text product_sn"></td><td><input name="product_name[' + item + '][]"  value="" style="width: 100%;" type="text" class="ui-text product_name"></td><td><input name="product_price[' + item + '][]" value="" style="width: 100%;" type="text" class="ui-text product_price"></td><td><input name="product_count[' + item + '][]" value="1" style="width: 100%;" type="text" class="ui-text product_count"></td><td><input name="product_attr[' + item + '][]" disabled value="" style="width: 100%;" type="text" class="ui-text product_attr"></td><td style="width: 70px;"><input type="button" class="ui-button" value="选择商品" onclick="selectItem(this)" /></td><td style="width: 70px;"><input type="button" class="ui-button" value="选择属性" onclick="selectAttr(this)" /></td><td style="width: 70px;"><input type="button" class="ui-button" value="删除商品" onclick="productItemDel(this)" /></td></tr>\n';
    $(_this).parents('.product-item').siblings('tr').find('table').append(productItem);
}
function productItemDel(_this) {
    $(_this).parents('.product-item-list').remove();
}
var productInput = null;
function selectItem(_this) {
    $.ajax({
        url: 'http://alizi.dr/alizi.php?m=Item&a=indexM&uid=1',
        success: function (res) {
            productInput = _this;
            layer.open({
                title: '选择商品',
                type: 1,
                skin: 'layui-layer-rim', //加上边框
                area: ['70%', '500px'], //宽高
                content: res,
                shadeClose: true,
            });
        }
    });
}
function selectAttr(_this) {
    $.ajax({
        url: 'http://alizi.dr/alizi.php?m=Item&a=attr&uid=1',
        success: function (res) {
            layer.open({
                title: '选择商品',
                type: 1,
                skin: 'layui-layer-rim', //加上边框
                area: ['70%', '500px'], //宽高
                content: res,
                shadeClose: true,
            });
        }
    });
}
</script>


<script type="text/javascript" charset="utf-8" src="__PUBLIC__/Assets/js/ueditor-1.4.3/ueditor.config.js?v=1"></script>
<script type="text/javascript" charset="utf-8" src="__PUBLIC__/Assets/js/ueditor-1.4.3/ueditor.all.js?v=1"></script>
<script type="text/javascript" charset="utf-8" src="__PUBLIC__/Assets/js/ueditor-1.4.3/lang/zh-cn/zh-cn.js?v=1"></script>


<script type="text/javascript">
 function setContent(contents,msg) {
     UE.getEditor('content').execCommand('insertHtml', contents)
     //UE.getEditor('content').setContent(contents, true);
     $.alert(msg?msg:'添加成功',1);
 }
 function insertHtml() {
     var value = prompt('插入html代码', '');
     UE.getEditor('content').execCommand('insertHtml', value)
 }
 UE.plugins["aliziPlugin"] = function() {
     var me = this, editor = this;
     var utils = baidu.editor.utils,
             Popup = baidu.editor.ui.Popup,
             Stateful = baidu.editor.ui.Stateful,
             uiUtils = baidu.editor.ui.uiUtils,
             UIBase = baidu.editor.ui.UIBase;
     var domUtils = baidu.editor.dom.domUtils;

     var clickPop = new baidu.editor.ui.Popup({
         content: "",
         editor: me,
         _remove: function() {
             $(clickPop.anchorEl).remove();
             clickPop.hide();
         },
         _blank: function() {
             $('<p><br/></p>').insertAfter(clickPop.anchorEl);
             clickPop.hide();
         },
         className: 'edui-bubble'
     });

     me.addListener("click",
         function(t, evt) {
             evt = evt || window.event;
             var el = evt.target || evt.srcElement;
             if (el.tagName == "IMG") {  return; }
             if ($(el).parents('.alizi-editor').size() > 0) {
                 el = $(el).parents('.alizi-editor:first').get(0);

                 current_active_ueitem = $(el);
                 clickPop.render();
                 var html = clickPop.formatHtml('<nobr class="alizi-poptools edui-default">模块：' + '<a href="javascript:;" onclick="$$._remove()" stateful>' + '删除</a>' + ' | <a href="javascript:;" onclick="$$._blank()" stateful>' + '其后插入空行</a>' + '</nobr>');
                 var content = clickPop.getDom('content');
                 content.innerHTML = html;
                 clickPop.anchorEl = el;
                 clickPop.showAnchor(clickPop.anchorEl);
             } else {
                 el.style.border="0";
                 if (current_active_ueitem) {  current_active_ueitem = null; }
             }
         });
 };
 var ue = UE.getEditor('content');
</script>
 {:W("Foot")}